#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>

#define ERR_EXIT(m)\
do{\
	perror(m);\
	exit(EXIT_FAILURE);\
}while(0)//#include<stdlib.h>

int main(int argc,char* argv[]){
	int fd[2];
	char buf[10]={0};

	if(pipe(fd)==-1)
		ERR_EXIT("pipe error");

	int pid=fork();
	if(pid==-1)
		ERR_EXIT("fork error");
	if(pid==0){
		close(fd[0]);
		if(write(fd[1],"Hello",5)==-1)
			ERR_EXIT("write error");

		close(fd[1]);
		exit(EXIT_SUCCESS);
	}

	close(fd[1]);
	if((read(fd[0],buf,sizeof(buf)))==-1)
		ERR_EXIT("read err");
	
	printf("%s\n",buf);
	close(fd[0]);

	return 0;
}